const express = require("express")
// 创建路由对象
const router = express.Router()

const feedbackService = require("../../service/manage/feedback")
// 导入验证表单数据的中间件
const expressJoi = require('@escook/express-joi')
// 导入需要的验证规则对象
const { id_p_schema } = require("../../schema/common")
const { list_schema, query_schema } = require("../../schema/manage/feedback")


router.use((req, res, next) => {
  if (req.auth?.type === 3 || req.auth?.type === 4) next() // pass control to the next handler
  else res.errSend("没有权限访问", 10002)
})

// 获取意见反馈列表
router.get("/", expressJoi(list_schema), feedbackService.getFeedbackList)
// 根据title查询意见反馈
router.get("/query", expressJoi(query_schema), feedbackService.queryFeedback)
// 获取意见反馈信息
router.get("/:id", expressJoi(id_p_schema), feedbackService.getFeedbackInfo)

module.exports = router
